package com.web.mqtt.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.web.common.iot.mqtt.api.MqttAclApi;
import com.web.common.iot.mqtt.entity.MqttAcl;
import com.web.common.iot.mqtt.entity.MqttAclEntity;
import com.web.common.result.R;
import com.web.common.result.ResultEnum;
import com.web.mqtt.service.impl.MqttAclServiceImpl;

/**
 * <p>
 * mqtt授权 前端控制器
 * </p>
 *
 * @author 
 * @since 2024-04-25
 */
@Tag(name = "MQTT授权")
@Controller
@RequestMapping("/iot/mqttAcl")
public class MqttAclController implements MqttAclApi {
	
	@Autowired
	private MqttAclServiceImpl mqttAclServiceImpl;

	@Operation(summary = "获取查询数据列表")
	@Override
	public R<IPage<MqttAclEntity>> getList(MqttAclEntity condition) {
		return mqttAclServiceImpl.getList(condition);
	}
	
	@Operation(summary = "保存数据信息")
	@Override
	public R<Object> saveInfo(MqttAcl mqttAcl) {
		return mqttAclServiceImpl.saveInfo(mqttAcl);
	}
	
	@Operation(summary = "更新数据信息")
	@Override
	public R<Object> updateInfo(MqttAcl mqttAcl) {
		if(mqttAcl.getMainId() == null) {
			return R.fail(null, ResultEnum.PARAMETER_ERROR);
		}
		return mqttAclServiceImpl.updateInfo(mqttAcl);
	}
	
	@Operation(summary = "删除数据信息")
	@Override
	public R<Object> deleteInfo(MqttAcl mqttAcl) {
		if(mqttAcl.getMainId() == null) {
			return R.fail(null, ResultEnum.PARAMETER_ERROR);
		}
		return mqttAclServiceImpl.deleteInfo(mqttAcl);
	}
}
